package dk.isten.andro.julesangbog;

import java.util.ArrayList;

import com.google.ads.AdView;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Sang_Act extends Activity implements OnClickListener {

	TextView sangtext;
	Button youtubebutton;
	String sang;

	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle extras = getIntent().getExtras();
        setContentView(R.layout.text_act);
        int position = extras.getInt("position");
        setTitle(Sang_List_Act.sange.get(position).getTitel());
        
        
        sang = "\"" + Sang_List_Act.sange.get(position).getTitel() + "\" + kor" ;
        System.out.println("\"" + Sang_List_Act.sange.get(position).getTitel() + "\"" );
        sangtext = (TextView) findViewById(R.id.textView1);
        sangtext.setText(Sang_List_Act.sange.get(position).getTekst());
        

        youtubebutton = (Button) findViewById(R.id.youtubebutton);
        
        youtubebutton.setOnClickListener(this);

        
        
        
        
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_front_act, menu);
        return true;
    }

	  // Called every time user clicks on a menu item
	  @Override
	  public boolean onOptionsItemSelected(MenuItem item)
	  { 
		  switch (item.getItemId()) 
		  {
		  		case R.id.support:
		  			startActivity(new Intent(this, SupportActivity.class));
		  			break;
		  }  
		  
		  return true;
	  }
	  
	@Override
	public void onClick(View v) {
		if(v==youtubebutton){
				
				Intent i = new Intent(Intent.ACTION_SEARCH);
				 i.setPackage("com.google.android.youtube");
				 i.putExtra("query", sang);
				 i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				 startActivity(i);
			}
		
	}
}
